package com.hy.erp.inventory.service;

import java.util.List ;

import javax.ejb.Stateless ;

import org.jboss.seam.ScopeType ;
import org.jboss.seam.annotations.Name ;
import org.jboss.seam.annotations.Scope ;
import org.jboss.seam.async.Schedule ;

import com.hy.enterprise.architecture.foundation.ArchitectureFoundationException;
import com.hy.enterprise.framework.service.business.AbstractBusinessService;
import com.hy.erp.inventory.dao.interfaces.IRewardsPunishmentDao;
import com.hy.erp.inventory.dao.interfaces.IUserDao;
import com.hy.erp.inventory.pojo.RewardsPunishment;
import com.hy.erp.inventory.pojo.interfaces.IRewardsPunishment;
import com.hy.erp.inventory.pojo.interfaces.IUser;
import com.hy.erp.inventory.service.interfaces.IRewardsPunishmentService;
/**
 * 
 * <ul>
 * <li>开发作者：汤莉</li>
 * <li>设计日期：2010-10-13；时间：上午09:17:36</li>
 * <li>类型名称：RewardsPunishmentService</li>
 * <li>设计目的：</li>
 * </ul>
 * <ul>
 * <b>修订编号：</b>
 * <li>修订日期：</li>
 * <li>修订作者：</li>
 * <li>修订原因：</li>
 * <li>修订内容：</li>
 * </ul>
 */
@Name("rewardsPunishmentService")
@Scope(ScopeType.SESSION)
@Stateless
public class RewardsPunishmentService
										extends
										AbstractBusinessService < IRewardsPunishment >
																				implements
																				IRewardsPunishmentService
{

	/**
	 * <ul>
	 * <li>开发作者：汤莉</li>
	 * <li>设计日期：2010-10-13；时间：上午09:18:26</li>
	 * <li>字段类型：long；字段名称：serialVersionUID</li>
	 * <li>设计目的：</li>
	 * </ul>
	 * <ul>
	 * <b>修订编号：</b>
	 * <li>修订日期：</li>
	 * <li>修订作者：</li>
	 * <li>修订原因：</li>
	 * <li>修订内容：</li>
	 * </ul>
	 */
	private static final long	serialVersionUID	=
														9202715670925617768L ;
	/**
	 * 
	 * 构造函数
	 */
	public RewardsPunishmentService()
	{
		super ( );
	}

	@ Override
	public String[] addRewardsPunishment(Object[] objects)
	{
		if(objects==null)
		{
			return null;
		}
		else
		{
			IRewardsPunishmentDao dao=( IRewardsPunishmentDao ) this.getDao ( IRewardsPunishment.class );
			RewardsPunishment[] punishment=new RewardsPunishment[objects.length];
			for ( int i =
							0 ; i < objects.length ; i ++ )
			{
				RewardsPunishment punishment2=( RewardsPunishment ) objects[i];
				punishment[i]=punishment2;
			}
			return dao.persist ( punishment ) ;
		}
	}

	@ Override
	public Integer removeRewardsPunishment (
												String [ ] Ids )
	{
		if ( ( null == Ids )
			     || ( Ids.length == 0 ) )
			{
				return new Integer (
				                     0 ) ;
			}
			else
			{
				IRewardsPunishmentDao dao=( IRewardsPunishmentDao ) this.getDao ( IRewardsPunishment.class );
				return dao.remove ( Ids );
			}
	}

	@ SuppressWarnings ( "unused" )
	@ Override
	public boolean modifyRewardsPunishment (
												RewardsPunishment punishment )
	{
		if ( ( null == punishment ) || ( null == punishment.getIdentifier ( ) ))
		{
			return true;
		}
		else
		{
			IRewardsPunishmentDao dao=( IRewardsPunishmentDao ) this.getDao ( IRewardsPunishment.class );
			IRewardsPunishment iRewardsPunishment=punishment;
			
			if ( null == iRewardsPunishment )
			{
				throw new ArchitectureFoundationException (
				                                            "修改用户实体数据时发生错误，所需要修改的实体在数据库中并不存在" ) ;
			}
			return (dao.merge ( iRewardsPunishment )!=null) ;
		}
		
	}


	@ SuppressWarnings ( "unused" )
	@ Override
	public List < IRewardsPunishment > getRewardsPunishmentById (
																	String [ ] Id )
	{
		if((Id.length!=0)||(Id!=null))
		{
			IRewardsPunishmentDao dao=( IRewardsPunishmentDao ) this.getDao ( IRewardsPunishment.class );
			return dao.findByIdentifier ( Id );
		}
		return null ;
	}

	@ Override
	public List < IRewardsPunishment > getAllRewardsPunishment ( )
	{
		IRewardsPunishmentDao dao=( IRewardsPunishmentDao ) this.getDao ( IRewardsPunishment.class );
		return dao.find ( ) ;
	}

	@ Override
	public List < IRewardsPunishment > getRewardsPunishmentByQueryName (
																			String queryName ,
																			Object [ ] args )
	{
		IRewardsPunishmentDao dao=( IRewardsPunishmentDao ) this.getDao ( IRewardsPunishment.class );
		return dao.findByNamedQuery ( queryName , args ) ;
	}

	@ Override
	public String [ ] modifyRewardsPunishment (
												Object [ ] objects )
	{
		if (  null == objects ) 
		{
			return null;
		}
		else
		{
			IRewardsPunishmentDao dao=( IRewardsPunishmentDao ) this.getDao ( IRewardsPunishment.class );
			RewardsPunishment[] types=new RewardsPunishment[objects.length];
            for(int i=0;i<objects.length;i++)
            {
            	RewardsPunishment type=( RewardsPunishment ) objects[i];
            	types[i]=type;
            }
			
			return dao.merge ( types );
		}
	}

}
